"""
mixin（混合模式）[java中的组合模式]的特点：
    1.mixin类功能单一
    2.不和基类关联，可以和任何基类组合，基类可以不和mixin关联就能初始化成功
    3.在mixin中不要使用super这种用法
"""

# 代码示例
"""
class GoodsListViewSet(CacheResponseMixin, mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet):

    # 增加限速
    throttle_classes = (UserRateThrottle, )

    queryset = Goods.objects.all()
    serializer_class = GoodsSerializer
    pagination_class = GoodsPagination
    filter_backends = (DjangoFilterBackend, filters.SearchFilter, filters.OrderingFilter)
    filter_class = GoodsFilter
    # 模糊查询
    search_fields = ('name', 'brief', 'desc')
    ordering_fields = ('sold_num', 'shop_price')

    def retrieve(self, request, *args, **kwargs):

        instance = self.get_object()
        # 点击数加1
        instance.click_num += 1
        instance.save()
        serializer = self.get_serializer(instance)
        return Response(serializer.data)

"""